//封装一个加¥加千位符
function moneyNum(obj,key){
    return obj && obj[key] ? `¥${format(obj[key])}` :0
}
//封装一个千位符的函数 参数是传递的数字
function format(val){
    //toLocaleString传递的是数字 但是传递的是字符串
    return Number(val).toLocaleString()
}
//封装一个加%的处理数据
function percentNum(obj,key){
    return obj && obj[key] ? `${obj[key]}%`:0
}
//封装一个加千位符的处理数据
function kilobitNum(obj,key){
    return obj && obj[key] ? `${format(obj[key])}` :0
}
//封装一个直接获取数据的图
function data(obj,key){
    return obj && obj[key] ?obj[key]:[]
}
function dataObj(obj,key){
    return obj && obj[key] ?obj[key]:{}
}
export default {
    inject:['getData'],
    computed:{
        //总数据
        getTopDate(){
            return this.getData()
        },
        //累计预售额
        salesToday(){
            return moneyNum(this.getTopDate,'salesToday')
        },
        //销售额日同比
        salesGrowthLastDay(){
            return percentNum(this.getTopDate,'salesGrowthLastDay')
        },
        //销售额月同比
        salesGrowthLastMonth(){
            return percentNum(this.getTopDate,'salesGrowthLastMonth')
        },
        //昨日销售额
        salesLastDay(){
            return moneyNum(this.getTopDate,'salesLastDay')
        },
        //累计订单量
        salesLastDay(){
            return moneyNum(this.getTopDate,'salesLastDay')
        },
        //订单量 order数据
        orderTrend(){
            return data(this.getTopDate,'orderTrend')
        },
        orderLastDay(){
            return kilobitNum(this.getTopDate,'orderLastDay')
        },
        orderToday(){
            return kilobitNum(this.getTopDate,'orderToday')
        },
        //今日交易用户数
        orderUser(){
            return kilobitNum(this.getTopDate,'orderUser')
        },
        userToday(){
            return kilobitNum(this.getTopDate,'userToday')
        },
        orderUserTrend(){
            return data(this.getTopDate,'orderUserTrend')
        },
        returnRate(){
            return percentNum(this.getTopDate,'returnRate')
        },
        //销售额日同比
        userGrowthLastDay(){
            return percentNum(this.getTopDate,'userGrowthLastDay')
        },
        //销售额月同比
        userGrowthLastMonth(){
            return percentNum(this.getTopDate,'userGrowthLastMonth')
        },
        userLastDay(){
            return data(this.getTopDate,'userLastDay')
        },
        userLastMonth(){
            return data(this.getTopDate,'userLastMonth')
        },
        orderFullYear(){
            return data(this.getTopDate,'orderFullYear')
        },
        orderFullYearAxis(){
            return data(this.getTopDate,'orderFullYearAxis')
        },
        userFullYear(){
            return data(this.getTopDate,'userFullYear')
        },
        userFullYearAxis(){
            return data(this.getTopDate,'userFullYearAxis')
        },
        orderRank(){
            return data(this.getTopDate,'orderRank')
        },
        userRank(){
            return data(this.getTopDate,'userRank')
        },
        category(){
            return dataObj(this.getTopDate,'category')
        }
    }
}